<template>
    <div class="login">
        <div>
            <div>
                <label for="password">密码：</label>
                <el-input v-model="password" placeholder="请输入密码" name='passsword' type='password'
                    @keyup.enter.native='login' show-password>
                </el-input>
            </div>
            <el-button type="primary" @click="login">登录</el-button>
        </div>
    </div>
</template>

<script type="text/javascript">
export default {
    name: 'login-vue',
    components: {
    },

    props: {},

    data() {
        return {
            password: "",
        }
    },

    watch: {},

    created() {
    },

    mounted() {
    },

    methods: {
        login() {
            if (!this.password) return this.$msg.warning({
                message: "账号或者密码不能为空",
                showClose: true,
                duration: 1000
            });
            this.$http.get('/mgr/login', {
                password: this.password,
            }).then((res) => {
                this.$msg.success({
                    message: "登录成功",
                    showClose: true,
                    duration: 1000
                });
                localStorage.clear();
                localStorage.setItem('userInfo', res.userInfo);
                this.$router.replace("/mgr/home");
            }).catch((err) => { err })
        },

    }
}
</script>

<style lang="less" scoped>
.login {
    width: 100%;
    height: 100%;
    position: relative;
    background: rgb(228, 227, 227);
    > div {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
    }
    div {
        width: 100%;
    }
    .el-input {
        width: 250px;
        margin: 10px 5px;
        display: inline-block;
    }
    .el-button {
        margin: 5px;
    }
}
</style>